import copy
from collections import deque

def BellmanFord(edges_value, N, src, dst, k):
    min_dist = [float('inf')] * (N+1)
    min_dist_new = [float('inf')] * (N+1)
    
    min_dist_new[src] = 0
    queue = deque()
    queue.append(src)
    
    while queue and k != -1:
        visited = [False]*(N+1)
        min_dist = copy.deepcopy(min_dist_new[:])
        k -= 1
        length = len(queue)
        for i in range(length):
            s = queue.popleft()
            for t, value in edges_value[s]:
                if min_dist[s] != float('inf') and min_dist[s]+value < min_dist_new[t]:
                    min_dist_new[t] = min_dist[s]+value
                    if not visited[t]:
                        queue.append(t)
                        visited[t] = True
                    
    return min_dist_new[dst]


def main():
    N, M = map(int, input().split())
    edges_value = [[] for i in range(N+1)]
    for i in range(M):
        s, t, value = map(int, input().split())
        edges_value[s].append([t,value])
    
    src, dst, k = map(int, input().split())
    
    min_cost = BellmanFord(edges_value, N, src, dst, k)
    if min_cost == float('inf'):
        print("unreachable")
    else:
        print(min_cost)

main()
